home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Amiga Public Domain Connection / APDC Disk #025 - Programming Languages (198x)(Amiga Public Domain Connection)(US)[WB].zip / APDC Disk #025 - Programming Languages (198x)(Amiga Public Domain Connection)(US)[WB].adf / Logo.Doc < prev    next >
Text File  |  1988-03-15  |  19KB  |  576 lines

  1.              ALOGO - © 1986 by Gerald Owens
  2.  
  3.     Permission is given for free, non-commercial distribution.
  4. This software is TRUE shareware:  If you have contributed something
  5. to the public domain, then you can keep it for free!  Otherwise, it is
  6. requested that you send a tax deductible donation of $5.00 to:
  7.  
  8.                Wycliffe Associates
  9.                Box 2000
  10.                Orange, Ca.   92669-9984
  11.  
  12.     Specify that the money is to go for literacy training in less
  13. developed countries, and tell them that "S" sent you.  Be sure to tell
  14. them not to send further information if you don't want it.
  15. Please direct all bug reports and suggestions for improvements to:
  16.  
  17.                Gerald Owens                   Gerald Owens
  18.                C/O William Richardson         C/O Amiga Atlanta
  19.                1599 Council Bluff Dr.         Box 7724
  20.                Atlanta, Ga.  30345            Atlanta, Ga.  30357
  21.  
  22. LIMITATIONS
  23.  
  24.      This is just the graphics portions of LOGO.  I have tried to
  25. follow the Apple II LOGO commands as closely as possible, with the
  26. exception of file, editor, and printer related commands.  Any good
  27. book on LOGO should be of help.
  28.  
  29. PROBLEM AREAS
  30.  
  31.      A single window is used for the editor, command, and graphics
  32. window.  Wierd things happen to the "turtle" when things get scrolled.
  33.  
  34.     Do not panic!  Repeat, do NOT panic if after successfully executing
  35. a procedure, you re-edit the buffer and find a blank screen!  The
  36. editor is fixed to place the cursor in front of the NEXT statement
  37. to be executed.  If there is an error, the cursor will be in front
  38. of the offending statement.  When a procedure returns, the cursor
  39. is temporarily placed after the END or the OUTPUT statement, so if
  40. the last procedure executed was the last procedure in the editor
  41. buffer, the cursor will be placed after the END statement, and so
  42. may appear alone on a blank screen.  Just press SHIFT-UP ARROW to
  43. get to your code.
  44.  
  45.      The editor is not very good.  I hope that if a later version comes
  46. out, it will be worthy of alternate use as a programmer's editor.
  47.  
  48.      The program polls the window message port constantly for a keypress
  49. while it executes, so that it can stop at a keypress.  Unfortunately,
  50. this takes up so much CPU time that it is virtually unable to be
  51. multi-processed.  My apologies.  I'm sure there's a work-around, but
  52. the Amiga is such a complicated machine that it will probably take a
  53. while for me to get sophisticated enough to implement it in assembler.
  54.  
  55.      There are no global variables.  All procedure variables are
  56. sort of local/global.  They're global in the sense that they are
  57. accessible outside of the procedure, and local in the sense that
  58. when a procedure is entered, the old value is saved, and when the
  59. procedure is exited, the old value is restored.  Every unique variable
  60. name is placed in a table and all accesses refer to that central
  61. copy, so the scope can be classified as being dynamic.  If you want
  62. global variables, declare a dummy procedure with "local" variables
  63. having the names of the desired global variables.
  64.  
  65.      Procedures and variables are declared using the editor.  They
  66. cannot be declared from the command processor.  When declaring a
  67. procedure, the header (TO <name> <vars>) MUST START on separate lines.
  68.  
  69.  
  70. HOW TO RUN
  71.      ALOGO cannot be executed from the Workbench.  Rather, get into the
  72. CLI and type in:
  73.  
  74. logo
  75.  
  76. [Note:  To open the CLI, it must be turned "On" in Preferences.  Then
  77. reboot.  The CLI icon will be in the System drawer of that Workbench disk.
  78. Click on it.  Enter "cd AMICUS_#18:logo" and then "logo" as above.]
  79.            
  80.  
  81. GENERAL COMMANDS
  82.  
  83.    These commands are in addition to the regular ALOGO commands, but
  84. only one command can be typed in on a line.
  85.  
  86. NEW
  87.    Clear the editor buffer.  Will prompt if contents have been
  88.    changed and not saved.
  89.  
  90. LOAD filename
  91.    Clears the editor buffer and loads the text file into the
  92.    editor buffer.  If the previous contents of the buffer was
  93.    changed and not saved, the computer will ask if it is OK
  94.    to delete the file.
  95.    ***WARNING*** Do not use a file name with an embedded blank.
  96.                  Even if it has ""'s around it!
  97.  
  98. SAVE
  99.    Without a file name, saves the editor buffer with the same
  100. name as it was previously loaded or saved under.
  101.  
  102.  
  103. SAVE filename
  104.    Saves the editor buffer under the new name, and records it so that
  105. "SAVE" without a file name saves under that file name.
  106.  
  107.  
  108. EDIT
  109.    Edit the editor buffer.  Press function key 'F1' to excape from the
  110. editor
  111.  
  112.  
  113. LIST
  114.    List the contents of the editor buffer on the screen.  Pressthe Right
  115. Mouse Button to temporarily stop the listing, and release it to
  116. allow the listing to continue.
  117.  
  118.  
  119. LLIST
  120.    Same as LIST, but the contents of the editor buffer are printed
  121. on the printer attached to your Amiga, followed by a Page-Eject.
  122.  
  123.  
  124. FILES
  125.    Same as the AmigaBASIC "FILES" command.  Lists the files in the
  126. current directory on the screen.  Requires that the "DIR" command be
  127. in the "C:" directory.
  128.  
  129.  
  130. QUIT
  131.    Leave logo and return to the operating system.
  132.  
  133.  
  134. EDITOR COMMANDS
  135.    Use the cursor keys to move up, down, left, and right.
  136.    Shift up-cursor moves the cursor up 10 lines.
  137.    Shift down-cursor moves the cursor down 10 lines.
  138.    Shift left-cursor move the cursor to the beginning of the line.
  139.    Shift right-cursor moves the cursor to the end of the line.
  140.    The grey DEL key deletes the character under the cursor.
  141.    The BACKSPACE key deletes the character just before the cursor.
  142.    Shift DEL key deletes an entire line.
  143.    Press RETURN to get a new line, or make a line into two lines.  Sorry,
  144.       no way to join two lines together as yet.
  145.    CTRL-Q, CTRL-X and F1 exits from the editor.
  146.  
  147.  
  148. EXPRESSIONS
  149.    An element can be any of the following:
  150.  
  151.    a.  A signed integer number (32 bits).  (-235, 447)
  152.    b.  A built-in variable.  (XCOR, YCOR, HEADING, and PENCOLOR.)
  153.    c.  A procedure call.  See the ALOGO command "OUTPUT" on how to
  154.        make a procedure return a value.  (COORD, FAC 4, DDT 77+2 99.)
  155.    d.  A user defined variable.  These start with a ":", followed by
  156.        a letter, and then followed by an optional sequence of letters
  157.        and digits.  (:a , :a1e2b4, :zzz).
  158.    
  159.    (As in the rest of ALOGO, it does not matter if the letters are
  160. in upper or lower case.  Thus, xcor, XCOR, and XcOr are all the same.)
  161.  
  162.    An expression is an element or an algebraic expression using elements.
  163. The following are valid expressions:
  164.  
  165.    5
  166.    :a+5
  167.    3*(:a-7)
  168.    :z/-9+ fac 6    (Procedure call of fac 6.  Result is added to :z/-9)
  169.    :Q % 6          (Remainder of :Q divided by 6)
  170.    -:r             (Negative of the value of :r)
  171.    xpos+4          (The value of built-in variable xpos has 4
  172.                     added to it)
  173.  
  174.    The following are valid operators to use in an expression.  They
  175. all behave the same as they do in AmigaBASIC.
  176.  
  177.    <  -  Less than, for comparing two numbers.
  178.    =  -  Equal to, for comparing two numbers.
  179.    >  -  Greater than, for comparing two numbers.
  180.    AND - Logical AND.
  181.    OR -  Logical OR.
  182.    NOT - Logical NOT.
  183.    *  -  Multiplication
  184.    /  -  Division
  185.    %  -  Modulo.  Same as MOD in AmigaBASIC.
  186.    +  -  Addition
  187.    -  -  Subtraction and negation.
  188.  
  189.    The precedence is as follows (same as for BASIC)
  190.  
  191.    ()'s        (To change the order of the precedence)
  192.    -           (Negation.)
  193.    * , / , %   (Same precedence.  Done left to right.  So 2*3*5/6 is
  194.                 (((2*3)*5)/6). )
  195.    + , -       (Same precedence.  Also done left to right.)
  196.    <,=,>       (Note:  <=,=>, and <> are NOT permitted.)
  197.    NOT
  198.    AND         (Done left to right.)
  199.    OR          (Done left to right.)
  200.  
  201.    Remember that ALOGO does not use anything to separate different
  202. expressions.  This can cause problems when using negation.
  203. As an example, if it is desired to print out 1 and -1 on the
  204. same line, the following command will NOT work:
  205.  
  206.    PRINT [1 -1]
  207.  
  208. It will print out 0, since 1-1 is 0.  To get 1 and -1 to be printed
  209. out separately, one must use:
  210.  
  211.    PRINT [1 (-1)]
  212.  
  213.  
  214. ALOGO BUILT-IN VARIABLES
  215.  
  216.    The following are the ALOGO built-in variables.  They hold the values
  217. of different aspects of the drawing pen.
  218.  
  219.  
  220. XCOR
  221.  
  222.    Holds the horizontal coordinate of the pen.  It will normally range
  223. from 0 to 610 in value.  0 is for the far left of the window, and
  224. 610 is for the far right of the window.
  225.  
  226.  
  227. YCOR
  228.  
  229.    Holds the vertical coordinate of the pen.  It will normally range
  230. from 0 to 182 in value, 0 is for the top of the window, and 182 is
  231. for the bottom of the window.
  232.  
  233.  
  234. HEADING
  235.  
  236.    Holds the heading of the pen, which is the direction in which the
  237. pen will move if given a FORWARD or BACK command.  It will range in
  238. value from 0 to 359.
  239.  
  240.  
  241. PENCOLOR
  242.  
  243.    Holds the present drawing color of the pen.  This will be a value
  244. from 0 to 3.  The exact color drawn will depend on the colors set in
  245. the preferences menu.
  246.  
  247.  
  248. ALOGO COMMENTS
  249.  
  250.    All ALOGO comments start with a ';', and continue to the end of the
  251. line, and can appear in any line.  For example:
  252.  
  253.          CS PD FD 10 ; this will not be executed >> LT 90 FD 10
  254.  
  255. will draw a line 10 steps long, but will not add the second line going
  256. to the left at the end of the first line.
  257.  
  258.  
  259. ALOGO COMMANDS
  260.  
  261.    The following commands can be typed in at the '>' prompt.  More
  262. than one command can be typed in on the same line.  To stop execution
  263. of the commands or any procedures, press a key on the Amiga keyboard.
  264.  
  265.    The words 'exp', 'exp1', 'exp2', and 'exp3' represent valid expressions
  266. as outlined above.  If none of these appear in the command, then the
  267. command does not take any parameters.
  268.  
  269.    Some of the commands can take a 2 letter abbreviation.  They can also
  270. be typed in in any mix of upper and lower case letters.
  271.  
  272.  
  273. CS
  274. CLEARSCREEN
  275.  
  276.    Clear the screen, put the drawing pen at the center of the screen,
  277. and set the direction to 0 degrees (up).  The pen is left up or down.
  278.  
  279.  
  280. HOME
  281.  
  282.    Put the drawing pen at the center of the screen and set the direction
  283. to 0 degrees (up).  The pen is left either up or down.
  284.  
  285.  
  286. CLEAN
  287.  
  288.    Just clear the screen, without affecting the pen location or whether
  289. the pen is up or down.
  290.  
  291.  
  292. PU
  293. PENUP
  294.  
  295.    Reset the pen so that the pen will not draw lines when moved.
  296.  
  297.  
  298. PD
  299. PENDOWN
  300.  
  301.    Set the Pen so that if the pen is moved, lines will be drawn.
  302.  
  303.  
  304. SETPC exp
  305.  
  306.    Set the pen color to the value of (exp % 4).  Pen colors are dependent
  307. on the Preferences settings, but they will map to the following colors
  308. on all screens:
  309.  
  310.             0 - Background color.
  311.             1 - Color of the letters and the border.
  312.             2 - Color of the Depth Arranger gadget in the upper
  313.                 right corner of the window.
  314.             3 - Color of the cursor.
  315.  
  316.  
  317. SETPOS [exp1 exp2]
  318.  
  319.    Set the pen to be at horizontal coordinate exp1, and vertical coordinate
  320. exp2.  (0,0) is at the upper left corner of the outside of the window, and
  321. (610,182) is at the lower right corner of the window.  If the pen is
  322. down, a line is drawn from the previous position to the new position.
  323. THE "[]"'S AROUND THE TWO EXPRESSIONS ARE MANDATORY.
  324.  
  325.  
  326. DOT [exp1 exp2]
  327.  
  328.    Places a dot of the present pen color at horizontal coordinate exp1
  329. and vertical coordinate exp2.  Exp1 can range from 0 to 610, and exp2
  330. can range from 0 to 182.  THE "[]"'s AROUND THE
  331. TWO EXPRESSIONS ARE MANDATORY.
  332.  
  333.  
  334. SETX exp
  335.  
  336.    Like SETPOS, but sets the horizontal coordinate only, leaving the
  337. vertical coordinate alone.  If the pen is down, then a line is drawn to
  338. the new position from the old position.
  339.  
  340.  
  341. SETY exp
  342.  
  343.    Like SETPOS and SETX, but sets the vertical coordinate only, leaving
  344. the horizontal coordinate alone.  If the pen is down, then a line is drawn
  345. to the new position from the old position.
  346.  
  347.  
  348. FD exp
  349. FORWARD exp
  350.  
  351.    Move in the direction of the heading of the pen (exp) many 'steps'.
  352. (There are 182 steps vertically and 304 horizontally.)  If the pen
  353. is down draw a line.  Note from SETPOS that a step in the horizontal
  354. direction is doubled.  This makes the aspect ratio close to 1:1, so
  355. that the logo statements "FD 10 LT 90 FD 10 LT 90 FD 10 LT 90 FD 10"
  356. forms more of a square than a rectangle.
  357.  
  358.  
  359. BK exp
  360. BACK exp
  361.  
  362.    Move in the opposite direction of the heading of the pen (exp)
  363. many 'steps'.  BK exp is the same as FD -(exp).
  364.  
  365.  
  366. LT exp
  367. LEFT exp
  368.  
  369.    Turn the heading of the pen's heading left (exp) degrees.  Directions
  370. on the screen are:
  371.  
  372.                    left   right
  373.                    <---   --->
  374.                         0
  375.                         ^
  376.                         |
  377.                   270 <-+-> 90
  378.                         |
  379.                         V
  380.                        180
  381.                    <---   --->
  382.                   right   left
  383.  
  384.  
  385. RT exp
  386. RIGHT exp
  387.  
  388.    Turn the heading of the pen's heading right (exp) degrees.  See the
  389. entry for LT and LEFT.   RT exp is the same as LT -(exp)
  390.  
  391.  
  392. SETH exp
  393. SETHEADING
  394.  
  395.    Turn the heading of the pen to the heading of (exp) degrees.  See the
  396. entry for LT and LEFT to see the directions to which the heading will
  397. translate.
  398.  
  399.  
  400. PRINT [ {exp | 'string'} {exp | 'string'} . . . ]
  401.  
  402.     Print the strings or the values of the expressions between the
  403. '[' and the ']'.  There can be as many expressions or as many strings,
  404. in any order, as you wish between the '[' and the ']'.  Strings
  405. *MUST* be surrounded by "'"'s.  The following lines print out
  406. various values.  The results are shown.
  407.  
  408.          PRINT [ 45*7 ' is 315']
  409. result:315  is 315
  410.  
  411.          PRINT ['this' ' is ' 'a' 'test']
  412. result:this is atest                   (put 'a ', rather than 'a', to
  413.                                         avoid this.)
  414.  
  415.          print [1*2 2*2 2*4]
  416. result:2 4 8
  417.  
  418.          PRINT [1*2 '+' 2*3 '=' 2*4]
  419. result:2 +6 =8
  420.  
  421.  
  422. MAKE "var exp
  423.  
  424.    Changes the value of the procedure variable to be the same as exp.
  425. Thus, if the value of :xxt is 17, then executing:
  426.  
  427.    MAKE "xxt :xxt+5
  428.  
  429. will change the value of :xxt to 22.  Note that the ":" is replaced
  430. by a double quote, which is required.  The values of built-in variables
  431. cannot be changed using MAKE.
  432.  
  433.  
  434. ALOGO CONTROL STATEMENTS
  435.  
  436.    The following statements affect the flow of control of the program.
  437. Only TO and END can be used in an editor buffer.  All the others can be
  438. typed in directly at the '>' prompt, and in the editor buffer.
  439.  
  440.  
  441. RP exp [stmt stmt ....]
  442. REPEAT exp [stmt stmt ....]
  443.  
  444.    Repeat all the statements between the '[' and the ']' (exp) times.
  445. If exp is less than or equal to 0, the statements between the '[]''s
  446. are not executed.  The following two lines draw the same squares.
  447.  
  448.          CS PD FD 40 LT 90 FD 40 LT 90 FD 40 LT 90 FD 40 LT 90
  449.  
  450.          CS PD REPEAT 4 [FD 40 LT 90]
  451.  
  452.    THE "[]"'s ARE REQUIRED.
  453.  
  454. IF exp [true statements] [false statements]
  455. IF exp [true statements]
  456.  
  457.    Tests the value of exp, and if true (not zero) all the statements
  458. between the first set of "[]"'s will be true.  If a second set of
  459. statements are between "[]"'s and are after the first set, they are
  460. skipped.  If the value of exp is false (zero), then the first set
  461. of statements between the "[]"'s is skipped, and the second set of
  462. statements between the second pair of "[]"'s is executed.  If a second
  463. set of statements does not exist (as in the second IF statement), then
  464. there is no error.  There IS an error if the "[]"'s are missing, or
  465. if there is no first set of statements.
  466.  
  467.  
  468. TO procedurename :variable :variable ....
  469. .
  470. .
  471. END
  472.  
  473.    Define a procedure named procedurename, with the variables after it
  474. as parameters.  Procedures cannot be defined directly, but must be typed
  475. into the editor buffer.
  476.  
  477.    TO *MUST* be at the beginning of the line, but END does not have to be on
  478. it's own line.  Failure to do so will cause ALOGO to complain that a
  479. procedure has not been defined.
  480.  
  481.    When the procedurename and parameters are typed in (using the same syntax
  482. as all the built-in commandss), all the statements between the TO and the
  483. END will be executed.
  484.  
  485.    ALOGO variables begin with a ':' followed by a letter, and can be
  486. composed of letters and digits.  ALOGO will not distinguish between
  487. upper and lower case letters, either in the procedure name or the
  488. variable names.
  489.  
  490.    Examples:
  491. ((these are typed into the editor buffer))
  492.  
  493.       to square :x  ;draw a square :x units on a side.
  494.          FD :x LT 90 FD :x LT 90 FD :x LT 90 FD :x LT 90
  495.       end
  496.  
  497.       to multisquare :x1 :turn :x   ;draw :x squares :x1 units on a side
  498.                                     ;turning :turn degrees between each
  499.                                     ;drawn square.
  500.          RP :x [square :x1 LT :turn]  ; this :x will not be confused with
  501.                                       ; the :x in square.  They are
  502.                                       ; different variables.
  503.       end
  504.  
  505. ((these are typed in at the '>' prompt))
  506.  
  507.      >square 50             ;draws a square 50 units on a side
  508.      >multisquare 30 10 36  ;draws 36 squares that are 30 units on a side
  509.                             ;turning 10 degrees between each square
  510.  
  511.    Trying to execute a procedure that is not defined in the editor buffer
  512. will cause ALOGO to complain.
  513.  
  514.    ALOGO procedures are like AmigaBASIC subroutines, and do not normally
  515. return a value.  To make a procedure return a value, so that it can be
  516. used in an expression, see the "OUTPUT" statement.
  517.  
  518.    ALOGO procedures can call other procedures, and can even call
  519. themselves.
  520.  
  521.  
  522. OUTPUT  exp
  523.  
  524.    To make a procedure return a value, use the OUTPUT statement.  The
  525. value returned will be the value of exp.  Some examples are:
  526.  
  527.    ((The following lines are typed into the Editor Buffer))
  528.  
  529.    to sum3 :x :y :z            ;return the sum of :x, :y, :z
  530.       output :x+:y+:z
  531.    end
  532.  
  533.    ((the following lines are typed at the ">" prompt.))
  534.  
  535.    >print [5*sum3 1 2 3]       ;do 5*(1+2+3)
  536. 30
  537.  
  538.    >print [sum3 1 2 3]         ;do 1+2+3
  539. 6
  540.  
  541.    The OUTPUT statement can be used anywhere, even in a set of statements
  542. between "[]"'s in the IF and REPEAT statements.  The execution of the
  543. IF or the REPEAT will be terminated, and the value returned to the
  544. procedure that called the procedure.  It is sort of like the AmigaBASIC
  545. RETURN statement.
  546.  
  547.  
  548. STOP
  549.  
  550.    Like the OUTPUT statement, the STOP statement stops the execution
  551. of a procedure and returns to the procedure that called the original
  552. procedure.  It is exactly like the AmigaBASIC RETURN statement.
  553.  
  554.  
  555. HALT
  556.  
  557.    This is like the AmigaBASIC STOP statement.  It stops the execution
  558. of all procedures and returns to the ">" prompt.  Pressing a key on
  559. the Amiga keyboard will have the same effect.
  560.  
  561.  
  562.  
  563. FINAL NOTES
  564.  
  565.      ALOGO V1.0 is written entirely in assembly language, which
  566. accounts partly for its speed and partly for its rough edges, since
  567. most of the programming examples provided by Commodore are oriented
  568. towards "C".  The headers of the procedures are partly compiled into
  569. a table for quick lookup, and are tied directly to the source code
  570. in the editor.  Changing a line in the editor forces this table to
  571. be recompiled.  I could have compiled all the procedures in the
  572. editor buffer in their entirety, but there would have been no direct
  573. connection between errors in the compiled code and where the error
  574. was located in the source.  Thus, in a child-oriented language, I opted
  575. for making the location of errors easy to do.
  576.